window.onload = function () {
    // 先找到所有行
    var allRows = document.getElementsByTagName('tr');
    var dataRows = [];
    for (var i = 1; i < allRows.length; i++) {
        dataRows.push(allRows[i]);
    }
}

// // 分页
// var pageLinks = document.querySelectorAll('.span');
// var currentPageSpan = document.querySelector('.page');

// 分页点击事件
// 等待DOM加载完成后再执行代码
document.addEventListener('DOMContentLoaded', function () {
    // 获取所有页码元素
    const pages = document.querySelectorAll('.page');

    // 给每个页码元素添加点击事件
    pages.forEach(page => {
        page.addEventListener('click', function () {
            // 先移除所有页码的 active 类
            pages.forEach(p => p.classList.remove('active'));
            // 给当前点击的页码添加 active 类
            this.classList.add('active');
        });
    });
});


//line分类
document.addEventListener('DOMContentLoaded', function () {
    const filterButtons = document.querySelectorAll('.filter');

    filterButtons.forEach(button => {
        button.addEventListener('click', function () {
            const targetRoute = this.getAttribute('route');
            const tableRows = document.querySelectorAll('table tr:not(:first-child)');

            tableRows.forEach(row => {
                const routeCell = row.querySelector('td:nth-child(4)');
                const rowRoute = routeCell.textContent.trim();

                if (rowRoute === targetRoute) {
                    row.style.display = '';
                } else {
                    row.style.display = 'none';
                }
            });
        });
    });

    // 点击单条数据时只显示该条数据
    const tableRows = document.querySelectorAll('table tr:not(:first-child)');
    tableRows.forEach(row => {
        row.addEventListener('click', function () {
            tableRows.forEach(r => {
                if (r === this) {
                    r.style.display = '';
                } else {
                    r.style.display = 'none';
                }
            });
        });
    });
    })

    
// const driverData = [
//     { id: 1, name: "张三", route: "Route 1" },
//     { id: 2, name: "李四", route: "Route 2" },
    


